package com.luo.partner.service.impl;

import java.util.List;
import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.luo.common.annotation.BaseService;
import com.luo.common.base.BaseServiceImpl;
import com.luo.common.utils.Query;
import com.luo.partner.dao.mapper.TabMonthlyKnotMapper;
import com.luo.partner.dao.mapper.ext.ExtTabMonthlyKnotMapper;
import com.luo.partner.dao.model.TabMonthlyKnot;
import com.luo.partner.dao.model.TabMonthlyKnotExample;
import com.luo.partner.dao.model.TabMonthlyKnotTemp;
import com.luo.partner.service.TabMonthlyKnotService;

/**
* TabMonthlyKnotService实现
* Created by laohu on 2018/9/6.
*/
@Service
@Transactional
@BaseService
public class TabMonthlyKnotServiceImpl extends BaseServiceImpl<TabMonthlyKnotMapper, TabMonthlyKnot, TabMonthlyKnotExample> implements TabMonthlyKnotService {

    private static final Logger LOGGER = LoggerFactory.getLogger(TabMonthlyKnotServiceImpl.class);

    @Autowired
    TabMonthlyKnotMapper tabMonthlyKnotMapper;
    
    @Autowired
    ExtTabMonthlyKnotMapper extTabMonthlyKnotMapper;

	@Override
	public TabMonthlyKnot get(Long id) {
		// TODO Auto-generated method stub
		return tabMonthlyKnotMapper.selectByPrimaryKey(id);
	}

	@Override
	public List<TabMonthlyKnot> list() {
		// TODO Auto-generated method stub
		return tabMonthlyKnotMapper.selectByExample(new TabMonthlyKnotExample());
	}

	@Override
	public int save(TabMonthlyKnot role) {
		// TODO Auto-generated method stub
		return tabMonthlyKnotMapper.insertSelective(role);
	}

	@Override
	public int update(TabMonthlyKnot role) {
		// TODO Auto-generated method stub
		return tabMonthlyKnotMapper.updateByPrimaryKey(role);
	}

	@Override
	public int remove(Long id) {
		// TODO Auto-generated method stub
		return tabMonthlyKnotMapper.deleteByPrimaryKey(id);
	}

	@Override
	public List<TabMonthlyKnot> list(Long userId) {
		TabMonthlyKnotExample example = new TabMonthlyKnotExample();
		example.or().andUserIdEqualTo(userId);
		return tabMonthlyKnotMapper.selectByExample(example);
	}

	@Override
	public int batchRemove(Long[] ids) {
		try {
			for (int i = 0; i < ids.length; i++) {
				tabMonthlyKnotMapper.deleteByPrimaryKey(ids[i]);
			}
		} catch (Exception e) {
			return 0;
		}
		return 1;
	}

	@Override
	public int count(Query query) {

		return tabMonthlyKnotMapper.countByExample(new TabMonthlyKnotExample());
	}

	@Override
	public int countList(Map<String, Object> map) {
		return extTabMonthlyKnotMapper.countList(map);
	}
	
	@Override
	public List<TabMonthlyKnotTemp> findList(Map<String, Object> map) {
		return extTabMonthlyKnotMapper.findList(map);
	}


}